import {
  BaseEntity,
  Column,
  CreateDateColumn,
  DeleteDateColumn,
  Entity,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';

@Entity()
export class Order extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({
    comment: '商品总数',
    nullable: false,
    unique: false,
    default: 0,
    type: 'int',
  })
  totalNumber: number;

  @Column({
    comment: '总金额',
    nullable: false,
    unique: false,
    default: 0,
    type: 'decimal',
    precision: 10,
    scale: 2,
  })
  totalAmount: number;

  @Column({
    comment: '地址',
    nullable: true,
    unique: false,
    default: null,
    type: 'varchar',
  })
  address: string;

  @Column({
    comment: '电话',
    nullable: true,
    unique: false,
    default: null,
    type: 'varchar',
  })
  phone: string;

  @Column({
    comment: '收件人',
    nullable: true,
    unique: false,
    default: null,
    type: 'varchar',
  })
  name: string;

  @Column({
    comment: '单号',
    nullable: true,
    unique: false,
    default: null,
    type: 'varchar',
  })
  expressNo: string;

  @Column({
    comment: '快递公司',
    nullable: true,
    unique: false,
    default: null,
    type: 'varchar',
  })
  expressName: string;

  @Column({
    comment: '订单确认时间',
    nullable: true,
    unique: false,
    default: null,
    type: 'datetime',
  })
  enterTime: Date;

  @Column({
    comment: '发货时间',
    nullable: true,
    unique: false,
    default: null,
    type: 'datetime',
  })
  sendTime: Date;

  @Column({
    comment: '到货时间',
    nullable: true,
    unique: false,
    default: null,
    type: 'datetime',
  })
  finishTime: Date;

  @Column({
    comment: '订单状态',
    nullable: true,
    unique: false,
    default: 0,
    type: 'int',
  })
  status: number;

  @Column({
    comment: '商品JSON',
    nullable: true,
    unique: false,
    default: null,
    type: 'text',
  })
  data: string;

  @Column({
    comment: '支付时间',
    nullable: true,
    unique: false,
    default: null,
    type: 'datetime',
  })
  payTime: Date;

  @Column({
    comment: '备注',
    nullable: true,
    unique: false,
    default: null,
    type: 'varchar',
  })
  remark: string;

  @CreateDateColumn()
  createTime: Date;

  @UpdateDateColumn()
  updateTime: Date;

  @DeleteDateColumn({ nullable: true })
  deleteTime: Date;
}
